<<<<<<< .mine
/** druhy prikazov a hodnoty
 */
var commands = ["---",Forward,Right,Left,Fx,Repeat];
var values = ["-","2","3","20","50","60","100","120","150"];
           
const commandSize = 12;    
const commandFont = "Consolas"; 
  
/**
 *
 * @class
 * @description Tlacidlo pre prikaz
 * @param array {Array} pole hodnot, ktore mozu byt v tlacitku
 * @param width {int}  sirka tlacice 
 *     
 */             
function CommandButton(array,width){
    Sprite.apply(this);
    this.values = array;
    this.index = 0;
    // chcem aby to bolo tlacidlo            
    this.buttonMode = true;
    this.mouseChildren = false;
    this.height = commandSize + commandSize/2;
    this.width = width;
        
    // primarne nastavenie textfieldu    
    this.text = new TextField();
    this.text.setTextFormat(CommandButton.tFormat);
    this.text.text = this.values[this.index]; 
    this.text.width = this.text.textWidth; 
    this.text.height = this.text.textHeight;
    this.text.x = this.width/2 - this.text.width/2;
    this.text.y = this.height/10;
    
    /**
    *
    * @function
    * @description funkcia nastavi text tlacidla na nasledujucu hodnotu v poli array 
    *     
    */ 
    this.nextValue = function(){
        var textChild = this.text;
        this.index = (this.index + 1) % this.values.length; 
        textChild.text = this.values[this.index];
        textChild.width = this.text.textWidth; 
        textChild.height = this.text.textHeight;
        this.text.x = this.width/2 - this.text.width/2;
    }

    // vykreslenie spodneho pozadia    
    this.graphics.beginFill(darkgrey);
    this.graphics.drawRect(0, 0, this.width, this.height);
	
	  // vykreslenie bieleho pozadia
    this.bg = new Sprite();		// bg is a layer with dark blue rectangle
    this.bg.graphics.beginFill(white);
    this.bg.graphics.drawRect(0, 0, this.width, this.height);
    this.addChild(this.bg);
	
    this.addChild(this.text);
    // pridanie listenerov    
    this.addEventListener(MouseEvent.MOUSE_OVER, this.onMOv);
    this.addEventListener(MouseEvent.MOUSE_OUT , this.onMOu);            
    this.addEventListener(MouseEvent.CLICK , this.onClick);                           
}
CommandButton.prototype = new Sprite(); 
CommandButton.tFormat   = new TextFormat(commandFont, commandSize, black);

//	methods
/**
* @function
* @description mouseOver. Ak niekto nadide nad tlacidlo mysou, tlacidlo zosedne
* @param e {event}     
*/ 
CommandButton.prototype.onMOv = function(e) {
    e.target.bg.visible = false;
}

/**
* @function
* @description mouseOut. Ak niekto odide z tlacidla mysou, tlacidlo sa zabieli
* @param e {event}     
*/ 
CommandButton.prototype.onMOu = function(e) {
    e.target.bg.visible = true;
} 

/**
* @function
* @description mouseClick. Ak niekto klikne na tlacidlo, tak sa nastavi nasledujuca hodnota
* @param e {event}     
*/ 
CommandButton.prototype.onClick = function(e) {
   e.target.nextValue();
} 


/**
 *
 * @class
 * @description Riadok prikazu. Pozostava z tlacidla pre command a tlacidla pre prisluchajucu value
 *     
 */   
function Command(){
    Sprite.apply(this);
    const MARGIN = 10;
    // sirka prikazov
    const commandWidth = 70;
    // sirka hodnot
    const valueWidth = 30;
    // sirka celeho commandu
    this.width = commandWidth + valueWidth + MARGIN; 
    
    // vytvorit button command
    this.commandButton = new CommandButton(commands, commandWidth);
    
    // vytvorit button pre value
    this.valueButton = new CommandButton(values, valueWidth);
    this.valueButton.x = commandWidth + MARGIN;
    
    // pridanie buttonov
    this.addChild(this.commandButton);
    this.addChild(this.valueButton);
    this.addEventListener(MouseEvent.CLICK , this.onClick);   
}
Command.prototype = new Sprite();  

/**
* @function
* @description mouseClick. Ak niekto klikne na tlacidlo a tlacidlo je typu Repeat a value > 3, tak nastavi hodnotu pre value "-"
* @param e {event}     
*/ 
Command.prototype.onClick = function(e) {
    var that = e.target.parent;
    var i = that.commandButton.index;
    if(commands[i] == Repeat){       // prikaz je repeat
        var j = that.valueButton.index;
        if(values[j] > 3){           // privelke mnozstvo cyklov
            that.valueButton.index = values.length - 1;
            that.valueButton.nextValue();
        }
    }
} 
 
 
 var nameFormat   = new TextFormat(commandFont, commandSize, white);
/**
 *
 * @class
 * @description  Panel reprezentujuci jednu funkciu pre korytnacku, meno
 * @param count {int} pocet prikazov
 * @param name {string} meno funkcie
 *     
 */  
function FunctionPanel(count, name){
    Sprite.apply(this);
    this.commands = new Array(count);
    this.width = (new Command().width);
    this.height = (count + 1)*(new Command().commandButton.height + 5);
    
    // Vykreslenie mena funkcie
    this.name = new TextField();
    this.name.setTextFormat(nameFormat);
    this.name.text = name; 
    this.name.x = 0; 
    this.name.y = 0;
    this.name.width = this.name.textWidth; 
    this.name.height = this.name.textHeight;
    this.addChild(this.name);
    
    // vytvorenie command riadkov podla vstupu do funkcie
    for(var i = 0;i < count;i++){
        this.commands[i] = new Command();
        this.commands[i].x = 0;
        this.commands[i].y = this.name.height + i*(this.commands[i].commandButton.height + 5);
        this.addChild(this.commands[i]);
    }
              
}
FunctionPanel.prototype = new Sprite();


/**
 *
 * @class
 * @description  Panel reprezentujuci cely program
 */  
function ProgramPanel(){
    Sprite.apply(this);
    
    // funkcia main
    this.main = new FunctionPanel(4,"Main");
    this.main.x =  0;
    this.main.y = MARGIN;
    this.addChild(this.main);
    
    // pomocna funkcia
    this.fun = new FunctionPanel(3,"Function");
    this.fun.x = this.main.width + MARGIN;
    this.fun.y = MARGIN;
    this.addChild(this.fun);
          
    this.width = this.main.width + this.fun.width + MARGIN;
    
    /**
  * @function
  * @description ziska pole prikazov zadanych do panela
  * @param panel {FunctionPanel}     
  */ 
    function getCommands(panel){
        var pole = new Array;
        var c = panel.commands;
        for(var i = 0;i < c.length;i++){
            var line = new Object();
            var indexCommand = c[i].commandButton.index;
            var indexValue = c[i].valueButton.index;
            line.command = commands[indexCommand];
            line.value = values[indexValue];
            if(line.command != commands[0]){
                pole.push(line);
            }
        }
        return pole;
    }
  
  /**
  * @function
  * @description ziska pole prikazov funkcie Main   
  */ 
    this.getMainCommands = function(){
        return getCommands(this.main);
    }
    
  /**
  * @function
  * @description ziska pole prikazov funkcie pomocnej   
  */ 
    this.getFunCommands = function(){
        return getCommands(this.fun);
    }
    
}
ProgramPanel.prototype = new Sprite();=======
var commands = ["---",Forward,Right,Left,Fx,Repeat];
var values = ["-","2","3","20","50","60","100","120","150"];
           
const commandSize = 12;    
const commandFont = "Consolas"; 
           
function CommandButton(array,width){
    Sprite.apply(this);
    this.values = array;
    this.index = 0;
                
    this.buttonMode = true;
    this.mouseChildren = false;
    this.height = commandSize + commandSize/2;
    this.width = width;
        
        
    this.text = new TextField();
    this.text.setTextFormat(CommandButton.tFormat);
    this.text.text = this.values[this.index]; 
    this.text.width = this.text.textWidth; 
    this.text.height = this.text.textHeight;
    this.text.x = this.width/2 - this.text.width/2;
    this.text.y = this.height/10;
    
    this.nextValue = function(){
        var textChild = this.text;
        this.index = (this.index + 1) % this.values.length; 
        textChild.text = this.values[this.index];
        textChild.width = this.text.textWidth; 
        textChild.height = this.text.textHeight;
        this.text.x = this.width/2 - this.text.width/2;
    }

        
    this.graphics.beginFill(darkgrey);
    this.graphics.drawRect(0, 0, this.width, this.height);
	
	
    this.bg = new Sprite();		// bg is a layer with dark blue rectangle
    this.bg.graphics.beginFill(white);
    this.bg.graphics.drawRect(0, 0, this.width, this.height);
    this.addChild(this.bg);
	
    this.addChild(this.text);
        
    this.addEventListener(MouseEvent.MOUSE_OVER, this.onMOv);
    this.addEventListener(MouseEvent.MOUSE_OUT , this.onMOu);            
    this.addEventListener(MouseEvent.CLICK , this.onClick);                           
}
CommandButton.prototype = new Sprite(); 
CommandButton.tFormat   = new TextFormat(commandFont, commandSize, black);

//	methods
CommandButton.prototype.onMOv = function(e) {
    e.target.bg.visible = false;
}
CommandButton.prototype.onMOu = function(e) {
    e.target.bg.visible = true;
} 

CommandButton.prototype.onClick = function(e) {
   e.target.nextValue();
} 
 
function Command(){
    Sprite.apply(this);
    const MARGIN = 10;
    const commandWidth = 70;
    const valueWidth = 30;
    this.width = commandWidth + valueWidth + MARGIN; 
    this.commandButton = new CommandButton(commands, commandWidth);
    
    this.valueButton = new CommandButton(values, valueWidth);
    this.valueButton.x = commandWidth + MARGIN;
    
    this.addChild(this.commandButton);
    this.addChild(this.valueButton);
    this.addEventListener(MouseEvent.CLICK , this.onClick);   
}
Command.prototype = new Sprite();  

Command.prototype.onClick = function(e) {
    var that = e.target.parent;
    var i = that.commandButton.index;
    if(commands[i] == Repeat){
        var j = that.valueButton.index;
        if(values[j] > 3){
            that.valueButton.index = values.length - 1;
            that.valueButton.nextValue();
        }
    }
} 
 
 
function FunctionPanel(count, name){
    Sprite.apply(this);
    this.commands = new Array(count);
    this.width = (new Command().width);
    this.height = (count + 1)*(new Command().commandButton.height + 5);
    
    this.name = new TextField();
    this.name.setTextFormat(CommandButton.tFormat);
    this.name.text = name; 
    this.name.x = 0; 
    this.name.y = 0;
    this.name.width = this.name.textWidth; 
    this.name.height = this.name.textHeight;
    this.addChild(this.name);
    
    for(var i = 0;i < count;i++){
        this.commands[i] = new Command();
        this.commands[i].x = 0;
        this.commands[i].y = this.name.height + i*(this.commands[i].commandButton.height + 5);
        this.addChild(this.commands[i]);
    }
              
}
FunctionPanel.prototype = new Sprite();

function ProgramPanel(){
    Sprite.apply(this);
    
    this.main = new FunctionPanel(4,"Main");
    this.main.x =  0;
    this.main.y = MARGIN;
    this.addChild(this.main);
    
    this.fun = new FunctionPanel(3,"Function");
    this.fun.x = this.main.width + MARGIN;
    this.fun.y = MARGIN;
    this.addChild(this.fun);
          
    this.width = this.main.width + this.fun.width + MARGIN;
    
    function getCommands(panel){
        var pole = new Array;
        var c = panel.commands;
        for(var i = 0;i < c.length;i++){
            var line = new Object();
            var indexCommand = c[i].commandButton.index;
            var indexValue = c[i].valueButton.index;
            line.command = commands[indexCommand];
            line.value = values[indexValue];
            if(line.command != commands[0]){
                pole.push(line);
            }
        }
        return pole;
    }
    
    this.getMainCommands = function(){
        return getCommands(this.main);
    }
    
    this.getFunCommands = function(){
        return getCommands(this.fun);
    }
    
}
ProgramPanel.prototype = new Sprite();>>>>>>> .r36
